const fs = require('fs');
const http = require('http');

http.createServer(function (req, res) {
  res.writeHead(200, {'content-type': 'text/html'});

  setTimeout(()=>{

    /** 1. 模拟程序错误导致进程退出*/
    //↓很明显后端是没有window的 会造成报错 (访问localhost3000,你会发现后台程序终止了
    console.log(window.location.href);

    const result = fs.readFileSync(__dirname + '/index.html', 'utf8');
    res.end(result);
  },50)

}).listen(3000,()=>{
  console.log('listened 3000');
});
